﻿using System;
using System.Net;

namespace SCG.SolarVengeanceEngine.StarShips
{
    public class DoomMissile : Missile
    {
        //constructor
        public DoomMissile(SVGame game, Player owner, int engines, int warheads, StarSystem origin)
            : base(game, owner, engines, warheads, origin)
        {
        }

        //Ship name
        public override string Name
        {
            get
            {
                return "DoomMissile";
            }
        }

        //description
        public override string Description
        {
            get
            {
                return "DoomMissiles can target a single StarSystem, and once targeted their orders cannot be changed.  They contain a number of Warheads, and each one that impacts a StarSystem reduces its Shields by 1 to 10 points, and reduces its Scanners by 1 to 3 points.  DoomMissiles are immune to StarTillery fire.";
            }
        }

        //ship type
        public override StarShipType ShipType
        {
            get
            {
                return StarShipType.DoomMissile;
            }
        }

        //Impact reduces shields and scanners
        protected override void TargetAdjacentStarSystem(StarSystem system)
        {
            for (int w = 0; w < Value; w++)
            {
                system.Shields -= (SVGame.RNG.Next(10) + 1);
                if (system.Shields < 0)
                    system.Shields = 0;
                system.Scanners -= (SVGame.RNG.Next(3) + 1);
                if (system.Scanners < 0)
                    system.Scanners = 0;
            }
            Game.SubmitStateChange(StateChange.SetShields, system, system.Shields);
            Game.SubmitStateChange(StateChange.SetScanners, system, system.Scanners);

            //Missile implementation handles destruction of missile and notification of clients
            base.TargetAdjacentStarSystem(system);         
        }
    }
}
